HW Java-1 To be submitted online. (Ill discuss next class) Copy the code in to blueJ and complete the following methods.
/** This is the shell of code to practice with variables * * @author J. Borland (change to your name) * @version 4.19 **/ public class PracticeVariables { //This method is to allow you to practice printing public static void practicePrinting() { echo ("test printing"); } //This method is to practice with variables public static void practiceVariables() { } //This method is to practice with methods with one parameter public static void findSquare(int x) { System.out.println("The code for this method needs to be added."); } //This method below is to practice with methods with parameters //You need to multiply the 2 numbers and print the product (nicely) //For example: The product of 5 and 6 is 30 public static void multiplyNumbers (int x, int y) { System.out.println("The code for this method needs to be added."); } //This method below is to find the next 2 numbers and print them out. //for example: (if they put in 12, it will print 13 and 14 are the next numbers) public static void findNextNums (int x) { System.out.println("The code for this method needs to be added."); } //This method below is to change some amount of money from US to Canadian //Currently the exchange rate is 1 US dollar = 1.34 Canadian dollars //So 8 us dollars = 8*1.34 //It would print: $8 US would be $10.72 Canadian public static void changeToCanadian (double usCurrency) { System.out.println("The code for this method needs to be added."); } //This method below is to change some amount of money from Canadian to US //Currently the exchange rate is 1 US dollar = 1.34 Canadian dollars //So 8 can dollars = 8/1.34 public static void changeToUS (double canCurrency) { System.out.println("The code for this method needs to be added."); } //This method will find the circumference given the radius and output that to screen public static void findCircumference(int radius) { System.out.println("The code for this method needs to be added."); } //This method finds the average of 2 numbers - careful. public static void findAverage(int number1, int number2) { System.out.println("The code for this method needs to be added."); } //Convert the celsius to fahr - F=9/5*C+32 public static void findFahr(double celsius) { System.out.println("The code for this method needs to be added."); } //*********************************************************************************************************// //ALL BELOW Extra credit (required for hot shots) //*********************************************************************************************************// //Use the quad formula to find both roots and print them out. //Look up quad formula if you forgot it. //To do square root, its Math.sqrt(the number) //For example double theSqRtOf25 = Math.sqrt(5); public static void findRoots(int a, int b, int c) { System.out.println("The code for this method needs to be added."); } //Find the total cost of an item below given a price and tax rate //So if the price was 100 and the tax rate was 7% it might say: //The tax is $7 and the total is $107 public static void findTax(double price, double taxRate) { System.out.println("The code for this method needs to be added."); } //*********************************************************************************************************// //Super Advanced - you will need loops, look them up. //*********************************************************************************************************// //Finds the least common multiple of x and y public static void findLCM(int x, int y) { System.out.println("The code for this method needs to be added."); } //Prints all the primes up to and including x - be efficient public static void findPrimes(int x) { System.out.println("The code for this method needs to be added."); } //The following 2 are just for printing faster public static void echo (String x){ // System.out.println(x); } public static void echo (int x){ System.out.println(x); } } |